import { Moment } from "moment";
import { Action } from "redux";
import { BudgetExhibit } from "../../interface/budgetData";
import { DataRowResult } from "../../interface/response";
import { ActionProps } from "../type";
import { BudgetDataActionEnum, DarkModeActionEnum, FilterDateActionEnum } from "./type";

/**
 * 切换暗黑模式和默认模式
 */
export const DarkModeActivated = (): Action<DarkModeActionEnum> => ({ type: DarkModeActionEnum.Dark });
export const DarkModeDeactivated = (): Action<DarkModeActionEnum> => ({ type: DarkModeActionEnum.Light });

/**
 * 获取头部展示数据
 */
export const SelectBudgetExhibitDate = (payload: BudgetExhibit[]): ActionProps<BudgetDataActionEnum, BudgetExhibit[]> => ({ type: BudgetDataActionEnum.Select, payload });
export const UpdateBudgetDate = (payload: DataRowResult): ActionProps<BudgetDataActionEnum, DataRowResult> => ({ type: BudgetDataActionEnum.Update, payload });
export const InsertBudgetDate = (payload: Object): ActionProps<BudgetDataActionEnum, Object> => ({ type: BudgetDataActionEnum.Insert, payload });
export const DeleteBudgetDate = (payload: Object): ActionProps<BudgetDataActionEnum, Object> => ({ type: BudgetDataActionEnum.Delete, payload });

/**
 * 设置获取时间,用于时间筛选参数
 */
export const GetFilterDate = (): Action<FilterDateActionEnum> => ({ type: FilterDateActionEnum.GetFilterDate });
export const SetFilterDate = (payload: Moment[]): ActionProps<FilterDateActionEnum, Moment[]> => ({ type: FilterDateActionEnum.SetFilterDate, payload });
